package com.yl.project.lvyou.video.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yl.framework.aspectj.lang.annotation.Log;
import com.yl.framework.aspectj.lang.enums.BusinessType;
import com.yl.project.lvyou.video.domain.ScenicVideo;
import com.yl.project.lvyou.video.service.IScenicVideoService;
import com.yl.framework.web.controller.BaseController;
import com.yl.framework.web.domain.AjaxResult;
import com.yl.common.utils.poi.ExcelUtil;
import com.yl.framework.web.page.TableDataInfo;

/**
 * 景区视频Controller
 * 
 * @author yl
 * @date 2025-03-12
 */
@Controller
@RequestMapping("/lvyou/video")
public class ScenicVideoController extends BaseController
{
    private String prefix = "scenemanager/video";

    @Autowired
    private IScenicVideoService scenicVideoService;

    @RequiresPermissions("scenemanager:video:view")
    @GetMapping()
    public String video()
    {
        return prefix + "/video";
    }

    /**
     * 查询景区视频列表
     */
    @RequiresPermissions("scenemanager:video:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ScenicVideo scenicVideo)
    {
        startPage();
        List<ScenicVideo> list = scenicVideoService.selectScenicVideoList(scenicVideo);
        return getDataTable(list);
    }

    /**
     * 导出景区视频列表
     */
    @RequiresPermissions("scenemanager:video:export")
    @Log(title = "景区视频", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ScenicVideo scenicVideo)
    {
        List<ScenicVideo> list = scenicVideoService.selectScenicVideoList(scenicVideo);
        ExcelUtil<ScenicVideo> util = new ExcelUtil<ScenicVideo>(ScenicVideo.class);
        return util.exportExcel(list, "video");
    }

    /**
     * 新增景区视频
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存景区视频
     */
    @RequiresPermissions("scenemanager:video:add")
    @Log(title = "景区视频", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ScenicVideo scenicVideo)
    {
        return toAjax(scenicVideoService.insertScenicVideo(scenicVideo));
    }

    /**
     * 修改景区视频
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ScenicVideo scenicVideo = scenicVideoService.selectScenicVideoById(id);
        mmap.put("scenicVideo", scenicVideo);
        return prefix + "/edit";
    }

    /**
     * 修改保存景区视频
     */
    @RequiresPermissions("scenemanager:video:edit")
    @Log(title = "景区视频", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ScenicVideo scenicVideo)
    {
        return toAjax(scenicVideoService.updateScenicVideo(scenicVideo));
    }

    /**
     * 删除景区视频
     */
    @RequiresPermissions("scenemanager:video:remove")
    @Log(title = "景区视频", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(scenicVideoService.deleteScenicVideoByIds(ids));
    }
}
